<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class Recommend extends Model
{
    const TABLE = 'recommend';

    //
    public function getArticleRecommend($type)
    {
        $list = DB::table(self::TABLE)
            ->leftJoin('article_title', 'article_title.id', '=', self::TABLE . '.article_title_id')
            ->leftJoin('user', 'user.id', '=', 'article_title.user_id')
            ->select('article_title.*', 'user.name')
            ->where(self::TABLE . '.type', $type)
            ->orderByDesc(self::TABLE . '.order')
            ->get();
        return $list;
    }
}
